<template>
	<view class="">
		<!-- <das-ipt @SearchEvents="search()" :prompt="'请输入姓名/日期/手机号'"></das-ipt> -->
		<view class="select">
			<view class="u-flex" @tap="showYear = true">
				<input style="color: #FFFFFF;" placeholder-style="color:#FFFFFF" class="ym" type="text" v-model="nowYear.showTime" disabled placeholder="请选择年月"/>
				<u-icon name="arrow-down-fill" color="#FFFFFF"></u-icon>
			</view>
			<u-picker mode="time" v-model="showYear" :params="params" @confirm="confirm"></u-picker>
		</view>
		<view class="all">
			<view class="list-item" v-for="(item,index) in dangerList" :key='index' @tap="$navTo('/pagesB/rithcheck/details/business?id='+item.id)">
				<view class="list-item-content">
					<view class="items">
						<text class="item-title">用户姓名：</text>
						<text class="colorhui">{{item.user_text.realname}}</text>
					</view>
					<view class="items">
						<text class="item-title">检查人姓名：</text>
						<text class="colorhui">{{item.staff_text.realname}}</text>
					</view>
					<view class="items">
						<text class="item-title">是否已安检：</text>
						<text class="colorhui">
							<template v-if="item.is_safe==1">
								是
							</template>
							<template v-if="item.is_safe==0">
								否
							</template>
						</text>
					</view>
					<view class="items">
						<text class="item-title">审核状态：</text>
						<text class="colorhui">
							<template v-if="item.status==1">
								未审核
							</template>
							<template v-if="item.status==2">
								已通过
							</template>
							<template v-if="item.status==3">
								未通过
							</template>
						</text>
					</view>
					<view class="items">
						<text class="item-title">修正仪底数：</text>
						<text class="colorhui">{{item.corrector_base}}</text>
					</view>
					<view class="items">
						<text class="item-title">油量：</text>
						<text class="colorhui">{{item.petrol}}</text>
					</view>
					<!-- <view class="items">
						<text class="item-title">计量柜品牌：</text>
						<text class="colorhui">{{item.meterage_brand}}</text>
					</view>
					<view class="items">
						<text class="item-title">燃气具品牌：</text>
						<text class="colorhui">{{item.gas_brand}}</text>
					</view> -->
					<!-- <view class="items">
						<text class="item-title">燃气具种类：</text>
						<text class="colorhui">{{item.gas_type}}</text>
					</view> -->
					<!-- <view class="items">
						<text class="item-title">功率：</text>
						<text class="colorhui">{{item.power}}</text>
					</view> -->
					<!-- <view class="items">
						<text class="item-title">本次检定日期：</text>
						<text class="colorhui">{{item.this_time}}</text>
					</view>
					<view class="items">
						<text class="item-title">下次检定日期：</text>
						<text class="colorhui">{{item.next_time}}</text>
					</view> -->
					<view class="items" v-if="item.remarks">
						<text class="item-title">备注：</text>
						<text class="colorhui">{{item.remarks}}</text>
					</view>
				</view>
				<!-- <view class="list-item-status">
					<image class="status-img" v-if="item.status==1" src="../../static/unchecked.png" mode=""></image>
					<image class="status-img" v-if="item.status==2" src="../../static/pagesB/jxz.png" mode=""></image>
					<image class="status-img" v-if="item.status==3" src="../../static/pagesB/ytj.png" mode=""></image>
					<image class="status-img" v-if="item.status==4" src="../../static/pagesB/tijiao.png" mode=""></image>
					<image class="status-img" v-if="item.status==5" src="../../static/pagesB/tongguo.png" mode=""></image>
					<image class="status-img" v-if="item.status==6" src="../../static/pagesB/butongguo.png" mode=""></image>
				</view> -->
			</view>
			<u-empty v-if="dangerList.length == 0" class="nomodel" text="暂无巡检记录" mode="list"></u-empty>
		</view>
	</view>
	
</template>

<script>
	export default {
		data() {
			return {
				dangerList: [],
				token: '',
				params: {
					year: true,
					month: true,
					day: false,
					hour: false,
					minute: false,
					second: false
				},
				showYear:false,
				// startYear:'',
				nowYear:{
					showTime:'', //前端展示的时间
					timeYear:'',  //传给后台的时间
				},
				id:''
			}
		},
		onShow() {
			uni.getStorage({
				key: 'token',
				success: (da) => {
					this.token = da.data;
				}
			})
			// var date = new Date();
			// let y = date.getFullYear();
			// let m = date.getMonth()+1;
			// this.startYear = y+'-'+m
		},
		onLoad(e) {
			this.id = e.id
			this.getInstallDetail()
		},
		methods: {
			// 获取安装数据
			getInstallDetail() {
				let that = this
				uni.request({
					url: this.$url + '/staff.business/getList',
					method: 'POST',
					header: {
						token: uni.getStorageSync('login')=='协管员'? uni.getStorageSync('token'):'',
					},
					data: {
						user_id:this.id,
						choose_time:this.nowYear.timeYear
					},
					success: (res) => {
						if (res.data.code == 1) {
							// console.log(res.data)
							that.dangerList = res.data.data;
							// console.log(that.dangerList)
						} else {
							that.$showToast(res.data.msg)
						}
					}
				})
			},
			search(e){
				console.log(e);
			},
			confirm(e){
				this.nowYear.showTime = e.year+'年'+e.month+'月'
				this.nowYear.timeYear = e.year +'-'+e.month
				this.getInstallDetail()
			},
			chooseYear(){
				this.showYear = true
			}
		}
	}
</script>

<style lang="less" scoped>
	.select{
		background: #003690;
		padding: 20rpx 30rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		.ym{
			min-width: 120rpx;
			max-width: 170rpx;
		}
	}
	.all {
		padding: 22rpx 32rpx;
		min-height: 100vh;
		background: #F1F1F1;
	}

	.list-item {
		background: #FFFFFF;
		box-shadow: 0rpx 4rpx 6rpx rgba(0, 30, 57, 0.1);
		border-radius: 16rpx;
		display: flex;
		padding: 0rpx 20rpx;
		margin-bottom: 22rpx;
		align-items: center;
		justify-content: space-between;

		.list-item-content {
			padding-bottom: 5rpx;

			.items {
				display: flex;
				align-items: center;
				padding: 5rpx 0;

				.portrait {
					width: 36rpx;
					height: 36rpx;
				}

				.item-title {
					width: 200rpx;
				}

				.colorhui {
					color: #999999;
					flex: 1;
					display: -webkit-box;
					 -webkit-box-orient: vertical;
					  -webkit-line-clamp: 1;
					   overflow: hidden;
				}
			}
		}

		.list-item-status {
			width: 171rpx;
			height: 174rpx;

			.status-img {
				display: block;
				width: 100%;
				height: 100%;
			}
		}
	}
</style>
